<?php

class mypdo{
    private $host;
    private $user;
    private $pass;
    private $db_name;
    private static $conn;
    private static $se;
    function __construct($host,$user,$pass,$db_name)
    {
        $this->host=$host;
        $this->user=$user;
        $this->pass=$pass;
        $this->db_name=$db_name;
         self::$conn=new PDO("mysql:host=$this->host;dbname=$this->db_name;charset=utf8",$this->user,$this->pass);
    }
    public static function seaocc_all($sql){  //获取整个数据
        $b=self::$conn->prepare($sql);
        $res=$b->execute();
        if($res){
            while($row=$b->fetch(PDO::FETCH_ASSOC)){
                self::$se[]=$row;

            }
            return self::$se;
        }
    }


    public static function  fied($sql){   //获取字段名
        $b=self::$conn->query($sql);
        $res="";
       foreach($b as $v){
           foreach($v as $vv => $kk){
               if(is_string($vv)){
                   $res[]=$vv;
               }
           }
           return $res;
       }

    }

    public static function upin($sql){        //更新插入数据
        $b=self::$conn->exec($sql);
        if($b){
            echo "ok!有".$b."条影响";

        }

    }
}